<include file="Public/min-header"/>
<style>
ul.group-list {
    width: 96%;min-width: 1000px; margin: auto 5px;list-style: disc outside none;
}
ul.group-list li {
    white-space: nowrap;float: left;
    width: 150px;
    list-style-type: none;
    list-style-position: outside;border: 0px;margin: 0px;
}
th.title {
    background: #F3F3F3;border-bottom: 1px solid #D7D7D7;font-weight: bold; white-space: nowrap;
}
</style>
<section class="wrapper"> 	
	<div class="row">
       	<div class="col-xs-12">      
		  <div class="panel">
            <div class="panel-heading"><i class="icon-gear"></i>设置角色
                <div class="pull-right">
                	<button type="button" id="pzReturn-btn" class="btn btn-default btn-xs" onclick="javascript:window.history.back();return false;"><i class="icon-reply"></i>返回</button>
                	<!-- <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回管理员列表"><i class="fa fa-reply"></i></a> -->
          		</div>
            </div>
            <div class="panel-body">	        	
				<form action="{:U('Admin/roleSave')}" id="roleform" method="post" class="tab-content">
					<input type="hidden" name="role_id" value="{$detail.role_id}" />					
					<div class="form-group">                                        
                        <label class="col-xs-1 control-label">角色名称</label>
                        <div class="col-xs-3">
                            <input type="text" class="form-control" name="data[role_name]" id="role_name" value="{$detail.role_name}" />
                        </div>
                        <label class="col-xs-1 control-label">角色描述</label>
                        <div class="col-xs-7">
                            <textarea class="form-control error" rows="1" name="data[role_desc]">{$detail.role_desc}</textarea>
                        </div>                                                          
                    </div>
                    <div class="inputCheckEditPerson">
			        	<p><i class="icon-tags"></i><b>权限分配：</b><label class="control-label"><input type="checkbox" onclick="choosebox(this)" /><span>全选</span></label></p>
						<table class="table table-bordered table-striped dataTable">
							<tbody>
							<foreach name="modules" item="menu" key="kk">			
									<tr>
										<td class="title left" style="padding-right:50px;">
											<i class="icon-tag"></i>
											<b>{$group[$kk]}：</b>
											<label class="right control-label"><input type="checkbox" value="1" cka="mod-{$kk}">全选</label>
										</td>
									</tr>
									<tr>
										<td>
											<ul class="group-list">
											<foreach name="menu" item="vv">
												<li><label class="control-label"><input type="checkbox" name="right[]" value="{$vv.id}" <if condition="$vv.enable eq 1">checked</if> ck="mod-{$kk}">{$vv.name}</label></li>
											</foreach>
											<div class="clear-both"></div>
											</ul>
										</td>
									</tr>
							</foreach>
							</tbody>							
						</table>
						<div class="pull-right">				
			                <button class="btn btn-primary" type="reset"><i class="icon-magic"></i>复原</button>
			                <button class="btn btn-submit" type="button" onclick="roleSubmit()">提交</button>			                   
						</div>
				</form>
		   </div>

		  </div>
		</div>
	</div>
</section>
<script type="text/javascript">
$(document).ready(function(){
	$(":checkbox[cka]").click(function(){
		var $cks = $(":checkbox[ck='"+$(this).attr("cka")+"']");
		if($(this).is(':checked')){
			$cks.each(function(){$(this).prop("checked",true);});
		}else{
			$cks.each(function(){$(this).removeAttr('checked');});
		}
	});
});

function choosebox(o){
	var vt = $(o).is(':checked');
	if(vt){
		$('input[type=checkbox]').prop('checked',vt);
	}else{
		$('input[type=checkbox]').removeAttr('checked');
	}
}

function roleSubmit(){
	if($('#role_name').val() == '' ){
		layer.alert('角色名称不能为空', {icon: 2});
		return false;
	}
	$('#roleform').submit();
}
</script>
</body>
</html>